<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	pageContext.setAttribute("path", path);
	pageContext.setAttribute("basePath", basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath %>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>个人信息</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.min.js"></script>
<!-- Custom Theme files -->
<!--theme-style-->
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />	
<!--//theme-style-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Wedding Store Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- start menu -->
<script src="js/simpleCart.min.js"> </script>
<!-- start menu -->
<link href="css/memenu.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="js/memenu.js"></script>
<script>$(document).ready(function(){$(".memenu").memenu();});</script>	
<!-- /start menu -->
<script type="text/javascript" src="js/cascading.js"></script>
<script type="text/javascript">
	var aprov_id = "${sessionScope.patriarch.pat_prov_id}";
	var acity_id = "${sessionScope.patriarch.pat_city_id}";
	var aarea_id = "${sessionScope.patriarch.pat_area_id}";
</script>
<script type="text/javascript">

	$(function(){
		var i = 0,j = 0;
		//失去焦点触发
		$("#pat_tel").blur(function(){
			var tel = $("#pat_tel").val();
			var sure_tel = $("#sure_tel").val();
			var pattern = /^[1][3,4,5,7,8][0-9]{9}$/;
			//满足格式，并且不是原来的，而是改变了的
	        if (pattern.test(tel)) {
	        	if (tel != sure_tel) {
	        		//首先判断手机号是否已经被注册
		        	$.post("login/existTel",{tel:tel,choose:"patriarch"},function(data){
		        		if (!data.meta.success) {
		        			alert(data.meta.message);
		        			$("#patriarch_submit").attr("disabled",true);
		        			i = 1;
		        		}else{
		        			i = 0;
		        			if(i == 0 && j == 0){
		        				$("#patriarch_submit").attr("disabled",false);
		        			}
		        		}
				    });
	        	}else {
	        		i = 0;
	    			if(i == 0 && j == 0){
	    				$("#patriarch_submit").attr("disabled",false);
	    			}
	        	}
	        	
	        }
		})
		
		//失去焦点触发
		$("#pat_account").blur(function(){
			var account = $("#pat_account").val();
			var sure_account = $("#sure_account").val();
			//满足格式，并且不是原来的，而是改变了的
	        if (account != sure_account) {
	        	//首先判断账号是否已经被注册
	        	$.post("patriarch/existAccount",{account:account},function(data){
	        		if (!data.meta.success) {
	        			alert(data.meta.message);
	        			$("#patriarch_submit").attr("disabled",true);
	        			j = 1;
	        		}else{
	        			j = 0;
	        			if(i == 0 && j == 0){
	        				$("#patriarch_submit").attr("disabled",false);
	        			}
	        		}
			    });
	        }else{
	        	j = 0;
    			if(i == 0 && j == 0){
    				$("#patriarch_submit").attr("disabled",false);
    			}
	        }
		})
	})
	
	$(function(){
		var message = $("#message").val();
		if (message != null && message != "") {
			alert(message);
			$("#message").val("");
		}
	})
	function addMoney(){
		let pat_balance = document.getElementById("pat_balance").value;
		if (pat_balance > 0) {
			var t = confirm("是否充值"+pat_balance+"元?")
			if (t) {
				document.getElementById("addMoney").submit();
			}
		}else{
			alert("请输入大于0的金额！");
		}
	}
</script>
</head>
<body> 
	<jsp:include page="../common/header.jsp"></jsp:include>
	<input type="hidden" id="message" value="${message }">
	<input type="hidden" id="sure_tel" value="${sessionScope.patriarch.pat_tel}">
	<input type="hidden" id="sure_account" value="${sessionScope.patriarch.pat_account}">
<!---->
<div class="contact">
	  <div class="container">
		 <ol class="breadcrumb">
		  <jsp:include page="../common/first.jsp"></jsp:include>
		  <li class="active">个人信息</li>
		 </ol>
			<!---start-contact---->
			<h3>个人信息</h3>
		  <div class="section group">	
		  		<div class="col-md-6 span_1_of_3">
					<div class="contact-form">
			    	 	<h4>充值余额</h4>
					   		<form action="patriarch/addMoney" method="post" id="addMoney">
					   			<input name="pat_id" type="hidden" value="${sessionScope.patriarch.pat_id }">
					   			<input name="pat_balance" id="pat_balance" type="number"  required style="border: 1px solid #ccc;height: 32px;width: 200px;"><br/>
					   			<input type="button" onclick="addMoney()" value="充值" style="margin-top: 10px;">
					   		</form>
      				</div>
				</div>		
		  			
				<div class="col-md-6 span_2_of_3">
				  <div class="contact-form">
					    <form action="patriarch/getPatriarch" method="post">
					    	<input name="pat_id" type="hidden" value="${sessionScope.patriarch.pat_id }">
					    	<div>
						    	<span><label>姓名</label></span>
						    	<span><input name="pat_name" type="text" value="${sessionScope.patriarch.pat_name }" required class="textbox"></span>
						    </div>
						    <div>
						    	<span><label>账号</label></span>
						    	<span><input name="pat_account" id="pat_account" type="text" value="${sessionScope.patriarch.pat_account }" class="textbox"></span>
						    </div>
						    <div>
						     	<span><label>电话</label></span>
						    	<span><input name="pat_tel" id="pat_tel" type="text" value="${sessionScope.patriarch.pat_tel }" pattern="^[1][3,4,5,7,8][0-9]{9}$" required class="textbox"></span>
						    </div>
						    <div>
						    	<span><label>账户余额</label></span>
						    	<span><input name="pat_balance" type="text" value="${sessionScope.patriarch.pat_balance }" readonly="readonly" class="textbox"></span>
						    </div>
						    <div>
						    	<span><label>地区</label></span>
						    	<span>
						    		<select name="pat_prov_id" id="prov"></select> 
						    		<select name="pat_city_id" id="city"></select> 
						    		<select name="pat_area_id" id="area"></select> 
						    	</span>
						    </div>
						    <div>
						    	<span><label>具体地址</label></span>
						    	<span><input name="pat_address" type="text" value="${sessionScope.patriarch.pat_address }" class="textbox"></span>
						    </div>
						    <div>
						    	<span><label>备注</label></span>
						    	<span><textarea name="pat_remark">${sessionScope.patriarch.pat_remark }</textarea></span>
						    </div>
						   <div>
						   		<span><input type="submit" id="patriarch_submit" class="mybutton" value="确定"></span>
						  </div>
					    </form>

				    </div>
  				</div>				
		  </div>
	  </div>
 </div>
<!-- footer  -->
<jsp:include page="../common/footer.jsp"></jsp:include>
</body>
</html>